﻿Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types

Public Class Addtype
    Dim objConn As OracleConnection
    Dim cmd As OracleCommand
    Dim Udone As New Err
    Dim Done As New Done
    Dim infor As New infor

    Private Sub Bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt1.Click
        Me.Close()
    End Sub

    Private Sub ADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ADD.Click

        If TextBox1.Text = "" Or TextBox2.Text = "" Then
            infor.ShowDialog()
        Else
            Dim strConnString As String = Login.strConn
            Dim cmd As New OracleCommand
            objConn = New OracleConnection(strConnString)
            Dim str1 As String = ""
            Dim str2 As String = ""

            str1 = TextBox1.Text
            str2 = TextBox2.Text

            Try
                Dim Sql As String = "Insert into TYPE (TYPE_ID,TYPE_MED) VALUES('" + str1 + "','" + str2 + "')"
                objConn.Open()
                With cmd
                    .Connection = objConn
                    .CommandText = Sql
                    .CommandType = CommandType.Text
                End With
                Try
                    cmd.ExecuteNonQuery()
                    Done.ShowDialog()
                Catch ex As Exception
                    Udone.ShowDialog()
                End Try
            Catch ex As Exception
                Udone.ShowDialog()
            Finally
                objConn.Dispose()
                TextBox1.Text = ""
                TextBox2.Text = ""
            End Try
 
        End If
    End Sub
End Class